#  pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt

import os

import pytest
from allure_combine import combine_allure

from core.CasesPlugin import CasesPlugin

test_dir=os.path.join(os.path.dirname(__file__),"core\ApiTestRunner.py")
pytest_args=['-v','-s',"--capture=sys",
             '--clean-alluredir',
             '--alluredir=allure-results',
             f'{test_dir}'
             ]
pytest.main(pytest_args)


"""
强制pytest加载我自定义的插件CasesPlugin()
可以优化core\ApiTestRunner.py里面的用例参数化代码
all_cases = case_parser('excel', r'D:\API\examples\excel_testcase')
data = all_cases['case_info']
@pytest.mark.parametrize("caseinfo", data)
"""
# pytest_args=['-v','-s',"--capture=sys",
#              '--clean-alluredir',
#              '--type=excel',
#              '--cases=./examples/excel_testcase',
#              '--alluredir=allure-results',
#              f'{test_dir}'
#              ]
# pytest.main(pytest_args,plugins=[CasesPlugin()])

# 生成测试报告 文件夹allure-report
os.system('allure generate -c -o allure-report')

combine_allure("./allure-report")